import Vue from 'vue';
import Router from 'vue-router';
import Layout from '@/layout/index.vue';

Vue.use(Router);
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/Login.vue'),
    hidden: true,
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: '/home',
      name: '首页',
      component: () => import('@/views/Home/index.vue'),
      meta:{ title:'首页',icon:'el-icon-s-home' }
    }]
  },
  {
    path: '/system',
    component: Layout,
    redirect:'/systempage',
    children: [
      {
        path: '/systempage',
        name: '系统设置',
        component: () => import('@/views/SystemSetup/index.vue'),
        meta: { title: '系统设置',icon:'el-icon-s-tools' }
      }
    ]
  },
  {
    path: '/user',
    name:'用户管理',
    component: Layout,
    meta:{ title:'用户管理',icon:'el-icon-platform-eleme' },
    children: [
      {
        path: '/test1',
        name:'用户管理测试1',
        component: () => import('@/views/User/test1.vue'),
        meta: { title: '测试1' },
      },
      {
        path: '/test2',
        name:'用户管理测试2',
        component: () => import('@/views/User/test2.vue'),
        meta: { title:'/测试2' }
      }
    ]
  }
];
const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes:constantRoutes,
  });

const router = createRouter();
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router;
